<template>
    <div class="nest">
        <el-form class="search-form" inline size="mini">
            <el-form-item>
                <el-input v-model="search.title" placeholder="用户id" clearable @change="getList" />
            </el-form-item>
            <el-form-item>
                <el-input v-model="search.title" placeholder="输入用户名" clearable @change="getList" />
            </el-form-item>
            <el-form-item>
                <el-select v-model="search.state" placeholder="身份" clearable @change="getList">
                    <el-option label="会员" value="1" />
                    <el-option label="普通用户" value="2" />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">查询</el-button>
                <el-button icon="el-icon-refresh-left" size="mini" @click="handleResetSearch">重置</el-button>
            </el-form-item>
            <!-- <addClassify ref="addClassify" @success="getList"></addClassify> -->
        </el-form>
        <div class="table">
            <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;">
                <el-table-column prop="id" label="用户ID" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="title" label="昵称" show-overflow-tooltip />
                <el-table-column prop="img" label="头像" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <el-avatar :size="60">
                            <img :src="scope.row.img" alt="">
                        </el-avatar>
                    </template>
                </el-table-column>
                <el-table-column prop="title" label="省份" show-overflow-tooltip />
                <el-table-column prop="title" label="城市" show-overflow-tooltip />
                <el-table-column prop="title" label="观看广告数" show-overflow-tooltip />
                <el-table-column prop="title" label="是否开通会员" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ `是` }}
                    </template>
                </el-table-column>
                <el-table-column prop="title" label="余额" show-overflow-tooltip />
                <el-table-column prop="title" label="会员到期时间" show-overflow-tooltip />
                <el-table-column prop="title" label="注册时间" show-overflow-tooltip />

                <!-- <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="$refs.addVip.handleEdit(scope.row)">详情</el-button>
                    </template>
                </el-table-column> -->
            </el-table>
            <div style="text-align: right;">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="search.page" :page-sizes="[10, 20, 30, 40, 100]" :page-size="search.size" background
                    layout="total, sizes, prev, pager, next" :total="total">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import addVip from "./addVip.vue"

export default {
    components: { addVip },
    data() {
        return {
            loading: false,
            search: {
                page: 1,	//true	int		当前页
                size: 10,	//true	int		每页多少条
            },
            tableData: [],
            total: 0,
            petList: {
                petCategoryList: [],
                petNestList: [],
            }
        }
    },
    created() {
        this.getList()
    },
    methods: {
        //用户等级列表
        async getList() {
            this.loading = true
            let res = await this.$request({
                url: '/admin/user.level/index',
                method: 'get',
            })            
            this.loading = false
            if (res.code == 200) {
                this.tableData = res.result
                this.total = res.result.length
            }
        },
        //分页
        handleSizeChange(e) {
            this.search.size = e;
            this.getList()
        },
        handleCurrentChange(e) {
            this.search.page = e;
            this.getList()
        },
    }
}
</script>

<style lang="scss">
.nest {
    width: 100%;
    height: 60px;

    .search-form {
        background: #fff;
        border-radius: 12px;
        padding: 12px 20px;
        margin-bottom: 20px;

        .el-form-item--mini.el-form-item {
            margin-bottom: 0;
        }
    }

    .table {
        padding: 12px 20px;
        background: #fff;
    }
}
</style>
